﻿using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace SailHero.Soft.ESB.Client
{
    class Demo
    {
        public void example()
        {
            CommunicationCommon comuCommon = new CommunicationCommon();
            comuCommon.MessageReceived += Client_MessageReceived;


            Socket ClientSocket = null;//传入系统实例化的socket实例
            comuCommon.ClientSocket = ClientSocket;
            comuCommon._running = true;
            ClientSocket.BeginReceive(comuCommon._buffer, 0, comuCommon._buffer.Length, 0, new AsyncCallback(comuCommon.ReceiveCallback), null);
        }


        private void Client_MessageReceived(object sender, MessageEventArgs e)
        {
            try
            {
                Message Tmsg = e.Message;
                //对消息进行处理
            }
            catch (Exception ex)
            {

                Errorlog.Write(ex);
            }
        }


    }
}
